<ui:component xmlns:ui="http://java.sun.com/jsf/facelets"
              xmlns:h="http://java.sun.com/jsf/html"
              xmlns:f="http://java.sun.com/jsf/core"
              xmlns:c="http://java.sun.com/jstl/core"
              xmlns:rich="http://richfaces.org/rich"
              xmlns:a4j="http://richfaces.org/a4j"

        >
    <link rel="stylesheet" type="text/css" href="./style/css/main.css"/>

    <style>
        .noMaskClass .rich-mpnl-mask-div {
            display: none;
        }
    </style>

    <!--@elvariable id="id" type="java.lang.String"-->
    <!--@elvariable id="header" type="java.lang.String"-->
    <!--@elvariable id="moveable" type="java.lang.Boolean"-->
    <!--@elvariable id="resizable" type="java.lang.Boolean"-->
    <!--@elvariable id="autosized" type="java.lang.Boolean"-->
    <!--@elvariable id="show" type="java.lang.Boolean"-->
    <!--@elvariable id="height" type="java.lang.Integer"-->
    <!--@elvariable id="width" type="java.lang.Integer"-->
    <!--@elvariable id="reRender" type="java.lang.Object"-->
    <!--@elvariable id="close" type="java.lang.Boolean"-->
    <!--@elvariable id="actionsBean" type="rs.contacts.core.ui.util.ActionsBean"-->
    <!--@elvariable id="confirmHide" type="java.lang.Boolean"-->
    <!--@elvariable id="cancelHide" type="java.lang.Boolean"-->
    <!--@elvariable id="closeParam" type="java.lang.Object"-->
    <!--@elvariable id="confirmParam" type="java.lang.Object"-->
    <!--@elvariable id="cancelParam" type="java.lang.Object"-->

    <rich:modalPanel id="#{id}"
                     moveable="#{empty moveable ? true : moveable}"
                     resizeable="#{empty resizable ? false : resizable}"
                     autosized="#{empty autosized ? true : autosized}"
                     showWhenRendered="#{empty show ? false : show}"
                     height="#{empty height ? 200 : height}"
                     width="#{empty width ? 300 : width}"
                     styleClass="noMaskClass">


        <f:facet name="header">
            <h:outputText value="#{header}"/>
        </f:facet>

        <f:facet name="controls">
            <a4j:form rendered="#{empty close ? true : close}">
                <a4j:commandButton id="closeButton_#{id}"
                                   action="#{actionsBean.close}"
                                   oncomplete="Richfaces.hideModalPanel('#{id}')"
                                   image="./style/images/close.PNG"
                                   styleClass="hidelink">
                    <a4j:actionparam assignTo="#{actionsBean.param}" value="#{closeParam}"/>
                </a4j:commandButton>
            </a4j:form>
        </f:facet>

        <c:if test="#{empty actionsBean.confirm and empty actionsBean.cancel}">

            <h:panelGroup layout="block">
                <ui:insert name="panelBody"/>
            </h:panelGroup>

        </c:if>
        <a4j:form id="form_#{id}">

            <c:if test="#{not empty actionsBean.confirm or not empty actionsBean.cancel}">
                <h:panelGroup layout="block">
                    <ui:insert name="panelBody"/>
                </h:panelGroup>
            </c:if>

            <h:panelGroup styleClass="buttons" layout="block">

                <a4j:commandButton id="confirmButton_#{id}"
                                   type="submit"
                                   styleClass="button"
                                   value="#{actionsBean.confirm}"
                                   action="#{actionsBean.confirm}"
                                   reRender="#{reRender}"
                                   oncomplete="if( #{empty confirmHide ? true : confirmHide} )Richfaces.hideModalPanel('#{id}')"
                                   rendered="#{not empty actionsBean.confirm}"
                        >
                    <a4j:actionparam assignTo="#{actionsBean.param}" value="#{confirmParam}"/>
                </a4j:commandButton>

                <a4j:commandButton id="cancelButton_#{id}"
                                   styleClass="button"
                                   type="reset"
                                   reRender="form_#{id}"
                                   action="#{actionsBean.cancel}"
                                   value="#{actionsBean.cancel}"
                                   oncomplete="if( #{empty cancelHide ? true : cancelHide} )Richfaces.hideModalPanel('#{id}')"
                                   rendered="#{not empty actionsBean.cancel}"
                        >
                    <a4j:actionparam assignTo="#{actionsBean.param}" value="#{cancelParam}"/>
                </a4j:commandButton>

            </h:panelGroup>
        </a4j:form>

    </rich:modalPanel>
    <script type="text/javascript" language="JavaScript">
        var #{id} = #{rich:component(id)};
        #{id}.lastOnfocus = function(event) {};
        #{id}.firstOnfocus = function(event) {};
        #{id}.processAllFocusElements = function(event) {};
        #{id}.processTabindexes = function(event) {};
        #{id}.restoreTabindexes = function(event) {};
        #{id}.preventFocus = function(event) {};
        #{id}.restoreFocus = function(event) {};
    </script>
</ui:component>